class Solution(object):
    def maxProfit(self, prices: list[int]) -> int:
        max_profit = 0
        if len(prices) > 1:
            left = 0
            right = 1
            while right < len(prices):
                if prices[right] > prices[left]:
                    max_profit += prices[right] - prices[left]
                left = right
                right = right + 1

        return max_profit

if __name__ == '__main__':
    s = Solution()
    prices = [7,1,5,3,6,4]
    print(s.maxProfit(prices))